package com.xb.loan.util.xmladapter.convert;

import javax.xml.bind.annotation.adapters.XmlAdapter;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateAdapter extends XmlAdapter<String, Date> {
 
    private static String pattern = "yyyyMMddHHmmss";
    
    private static SimpleDateFormat sdf = new SimpleDateFormat(pattern);
     
    @Override
    public Date unmarshal(String dateStr) throws Exception {
         
        return sdf.parse(dateStr);
    }
 
    @Override
    public String marshal(Date date) throws Exception {
        
    	if(date == null){
    		
    		return ""; 
    	}
        return sdf.format(date);
    }
 
}